/*************************************************
* Title：TinyToolKit
* Author：Opportunity 
* Discribe：Path类的扩展
* CreateTime：2020-04-05 21:52:45
* Version：1.0
* Modify Recoder：
*************************************************/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace TinyToolKit
{
    public static partial class TinyUtility
    {
        public static class Path
        {
            public static string GetPathWithoutExtension(string path)
            {
                int index = -1;
                index = path.LastIndexOf(".");
                if (index >= 0)
                    path = path.Remove(index);
                return path;
            }

            /// <summary>
            /// 规范化路径，将‘\’都替换为'/'
            /// </summary>
            /// <param name="oriPath"></param>
            /// <returns></returns>
            public static string GetRegularPath(string oriPath)
            {
                if (string.IsNullOrEmpty(oriPath)) return string.Empty;

                return oriPath.Replace('\\', '/');
            }

            /// <summary>
            /// 提供不同平台加载StreamingAssets文件夹的方法
            /// </summary>
            /// <returns>返回StreamingAssets文件夹的路径</returns>
            public static string GetStreamingAssetsPath()
            {
                string path = "";
#if UNITY_ANDROID
           path="jar:file://" + Application.dataPath + "!/assets/";
#elif UNITY_IPHONE
           path= Application.dataPath+"/Raw/";
#else
           path = Application.streamingAssetsPath + "/";
#endif
                return path;
            }

            public static string GetPersistentDataPath() 
            {
                return Application.persistentDataPath + "/";
            }
        }
    }
}
